﻿using MediatR;
using SheepStorage.API.Application.Command.DepartmentCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.InputDto;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.DepartmentHandler
{
    public class DepartmentMenuCommandHandler : IRequestHandler<DepartmentMenuCommand, Results<List<Cascader>>>
    {

        private readonly IDepartmentService departmentService;

        public DepartmentMenuCommandHandler(IDepartmentService departmentService)
        {
            this.departmentService = departmentService;
        }   

        public async Task<Results<List<Cascader>>> Handle(DepartmentMenuCommand request, CancellationToken cancellationToken)
        {
            var list = await departmentService.GetCascader(request.DepartmentParentId);
            return Results<List<Cascader>>.DataResult(list);    
        }
    }
}
